#encoding:utf-8 

import os , sys , commands


BIN_DIR = os.getcwd() + os.sep + "bin"
BIN_MAP = dict(
	win32 = {"php":BIN_DIR + os.sep + "php" + os.sep + "php.exe" , "luajit":BIN_DIR + os.sep + "luajit" + os.sep + "luajit.exe"},

	)
PHP_CONSOLE = BIN_DIR + os.sep + "phptool" + os.sep + "compile_scripts.php"


def luacomplieDir(basedir , tarfile):
	#clear first
	if os.path.isfile(tarfile):
		os.remove(tarfile)

	#command str
	str_comand = "{phpbin} {phptool} -m zip -jit -i %s -o %s" % (basedir , tarfile)


	bin_php = BIN_MAP[sys.platform]["php"]
	bin_luajit = BIN_MAP[sys.platform]["luajit"]
	bin_phptool = PHP_CONSOLE

	str_comand = str_comand.replace("{phpbin}", bin_php)
	str_comand = str_comand.replace("{luabin}", bin_luajit)
	str_comand = str_comand.replace("{phptool}", bin_phptool)
	os.system(str_comand)

def luacomplieFile(basefile , tarfile):
	print ("complie file")